#!/bin/bash
counter=0
while (( $counter<26 ))
do
  #wait(data)
  bash wait.sh data.txt 
  #wait(free)
  bash wait.sh free.txt
  # inspect the first line of the buffer and then remove it
  #s=$(<"buffer.txt")
  #echo -e "consume a \c"
  C=$(cat buffer.txt)
  s=$(echo ${C:0:1}) 
  echo "consume a $s"
  sed -i '1d' buffer.txt
  let "counter++"
  #signal(free)
  bash signal.sh free.txt 
  #signal(space)
  bash signal.sh space.txt
done
echo "Consumption Completed!"
exit
